package com.flight.trans.adapter;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.bean.LeavePortCollectCheckDetailBean.LeavePortCollectCheckDetailData.CheckItemData;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;

import java.util.List;

/**
 * 出港提货
 */
public class LeavePortCollectCheckDetailsAdapter extends BaseRecyclerAdapter<CheckItemData> {

    public LeavePortCollectCheckDetailsAdapter(Context mContext, List<CheckItemData> mList , boolean IsEditor) {
        super(mContext, mList);
        this.IsEditor = IsEditor ;
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_leave_port_collect_check_details;
    }

    @Override
    protected void bindData(BaseViewHolder holder, CheckItemData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);
        TextView mTvCheckItem = holder.findViewById(R.id.mTvCheckItem);
        TextView mTvConsentStatus = holder.findViewById(R.id.mTvConsentStatus);
        TextView mTvRemarks = holder.findViewById(R.id.mTvRemarks);

        mTvCheckItem.setText(data.getName());
        mTvRemarks.setText(data.getRemark());

        switch (data.getType()){
            case 0 :
                // 通过
                mTvConsentStatus.setText(mContext.getString(R.string.text_yes));
                mLlContainerItem.setBackgroundColor(mContext.getResources().getColor(R.color.color_green));
                break;
            case 1:
                // 不通过
                mTvConsentStatus.setText(mContext.getString(R.string.text_no));
                mLlContainerItem.setBackgroundColor(mContext.getResources().getColor(R.color.color_red));
                break;
            case 2:
                // 不适用
                mTvConsentStatus.setText(mContext.getString(R.string.text_not_applicable));
                mLlContainerItem.setBackgroundColor(mContext.getResources().getColor(R.color.color_yellow));
                break;
        }


        mTvCheckItem.setTextColor(mContext.getResources().getColor(data.getType() == 2 ? R.color.black : R.color.white));
        mTvConsentStatus.setTextColor(mContext.getResources().getColor(data.getType() == 2 ? R.color.black : R.color.white));
        mTvRemarks.setTextColor(mContext.getResources().getColor(data.getType() == 2 ? R.color.black : R.color.white));

        if(IsEditor) {
            setOnTextClickListener(mTvCheckItem , position);
            setOnTextClickListener(mTvConsentStatus, position);
            setOnTextClickListener(mTvRemarks, position);
        }
    }
}
